/* 基础样式和变量 */
:root {
    --primary-color: #4a6fa5;
    --secondary-color: #6c8ebd;
    --xml-color: #6a8759; /* XML转换工具颜色 */
    --validator-color: #cc7832; /* 格式校验工具颜色 */
    --warning-color: #cc4e32;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --tip-background: #e3f2fd;
}

/* 暗黑模式变量 */
[data-theme="dark"] {
    --primary-color: #5b8ad6;
    --secondary-color: #7fa3d7;
    --xml-color: #8aac6c; /* 暗黑模式下的XML转换工具颜色 */
    --validator-color: #d6936b; /* 暗黑模式下的格式校验工具颜色 */
    --background-color: #1a1a2e;
    --card-background: #222438;
    --text-color: #e0e0e0;
    --border-color: #444444;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --tip-background: #1a2a3a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
header {
    /* display: flex;
    justify-content: space-between;
    align-items: center; */
    /* margin-bottom: 20px; */
    padding-bottom: 15px;
    padding-top: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-background);
    position: relative;
    z-index: 1000;
}

/* 头部左侧区域 */
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

/* Logo样式 */
.logo {
    font-size: 18px;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 6px;
}

/* 主导航样式 */
.main-navigation {
    display: flex;
    gap: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.nav-link:hover {
    background-color: var(--tip-background);
    color: var(--primary-color);
}

.nav-link i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

/* 下拉菜单样式 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow-color);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown:hover .nav-link i {
    transform: rotate(180deg);
}

.dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background-color: var(--tip-background);
    color: var(--primary-color);
    padding-left: 20px;
}

/* 页面标题样式 */
.page-title {
    text-align: center;
    margin-bottom: 20px;
}

.page-title h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin: 0;
}

/* 暗黑模式下的导航样式 */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--card-background);
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .dropdown-menu a {
    border-color: #444;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-left {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .main-navigation {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        background-color: transparent;
        min-width: auto;
    }
    
    .dropdown:hover .dropdown-menu {
        display: block;
    }
    
    .page-title h1 {
        font-size: 1.5rem;
    }
}



header h1 {
    font-size: 2rem;
    color: var(--primary-color);
}

/* 主内容区域 */
main {
    flex: 1;
}

.editor-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 400px;
}

@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
        height: auto;
    }
}

/* 输入区域 */
.input-section, .output-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    padding: 20px;
    transition: background-color 0.3s, box-shadow 0.3s;
    position: relative;
    width: 48%;
    min-width: 320px;
}

.input-section {
    min-width: 320px;
}

.input-section h2, .output-section h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

#json-input {
    flex: 1;
    width: 100%;
    height: 500px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    resize: none;
    background-color: var(--card-background);
    color: var(--text-color);
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
    /* 优化滚动性能 */
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    /* 长文本优化 */
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

/* 输入区域滚动条样式 */
#json-input::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#json-input::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 6px;
}

#json-input::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 6px;
    border: 2px solid var(--background-color);
    transition: background-color 0.3s;
}

#json-input::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

#json-input::-webkit-scrollbar-corner {
    background: var(--background-color);
}

/* 暗黑模式下的输入区域滚动条 */
[data-theme="dark"] #json-input::-webkit-scrollbar-track {
    background: var(--card-background);
}

[data-theme="dark"] #json-input::-webkit-scrollbar-thumb {
    background: #555;
    border-color: var(--card-background);
}

[data-theme="dark"] #json-input::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

[data-theme="dark"] #json-input::-webkit-scrollbar-corner {
    background: var(--card-background);
}

#json-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.button-group {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s, transform 0.1s;
}

/* button:hover {
    background-color: var(--secondary-color);
} */

button:active {
    transform: scale(0.98);
}

#clear-btn {
    background-color: #7f8c8d;
}

#clear-btn:hover {
    background-color: #95a5a6;
}

.error-message {
    display: none;
    color: var(--error-color);
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

.error-message.show {
    display: block;
}

/* 输出区域 */
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.copy-btn, .edit-btn, .save-btn, .cancel-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    font-size: 14px;
}

.edit-btn {
    background-color: #3498db;
}

.edit-btn:hover {
    background-color: #2980b9;
}

.save-btn {
    background-color: #27ae60;
}

.save-btn:hover {
    background-color: #219653;
}

.cancel-btn {
    background-color: #e74c3c;
}

.cancel-btn:hover {
    background-color: #c0392b;
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

#json-output {
    flex: 1;
    width: 100%;
    height: 300px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    overflow: auto;
    background-color: var(--card-background);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    /* 优化滚动性能 */
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    /* 长文本优化 */
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

/* 自定义滚动条样式 */
#json-output::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#json-output::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 6px;
}

#json-output::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 6px;
    border: 2px solid var(--background-color);
    transition: background-color 0.3s;
}

#json-output::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

#json-output::-webkit-scrollbar-corner {
    background: var(--background-color);
}

/* 暗黑模式下的滚动条 */
[data-theme="dark"] #json-output::-webkit-scrollbar-track {
    background: var(--card-background);
}

[data-theme="dark"] #json-output::-webkit-scrollbar-thumb {
    background: #555;
    border-color: var(--card-background);
}

[data-theme="dark"] #json-output::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

[data-theme="dark"] #json-output::-webkit-scrollbar-corner {
    background: var(--card-background);
}

/* 复制通知 */
.copy-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--success-color);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.copy-notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* 页脚样式 */
footer {
    background-color: var(--card-background);
    color: var(--text-color);
    padding: 40px 0 20px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-main {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.footer-section {
    flex: 1;
    min-width: 220px;
}

.footer-section h3 {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text-color);
    font-weight: 600;
    position: relative;
    padding-bottom: 10px;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 30px;
    height: 2px;
    background-color: var(--primary-color);
}

.footer-section p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-color);
    opacity: 0.8;
}

.footer-section.about-us {
    flex-basis: 8%;
}

.footer-section.links ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section.links .links-columns {
    display: flex;
    gap: 40px;
}

.footer-section.links li {
    margin-bottom: 10px;
}

.footer-section.links a {
    color: var(--text-color);
    opacity: 0.8;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s, padding-left 0.3s, opacity 0.3s;
}

.footer-section.links a:hover {
    color: var(--primary-color);
    padding-left: 5px;
    opacity: 1;
}

.social-icons {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.social-icons a {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 20px;
    transition: color 0.3s, transform 0.3s, opacity 0.3s;
}

.social-icons a:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
    opacity: 1;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.7;
    flex-wrap: wrap;
    gap: 10px;
}

.footer-legal a {
    color: var(--text-color);
    opacity: 0.7;
    text-decoration: none;
    margin-left: 15px;
    transition: color 0.3s, opacity 0.3s;
}

.footer-legal a:hover {
    color: var(--primary-color);
    opacity: 1;
}



@media (max-width: 768px) {
    .footer-main {
        flex-direction: column;
    }
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
}

/* 头部控件区域 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 分享按钮 */
.share-button {
    display: flex;
    align-items: center;
    gap: 8px; /* Adjusted gap for new padding */
    padding: 2px 6px; /* Adjusted padding for height (target 30px) and aesthetics */
    background-color: var(--secondary-color); /* To match theme-toggle's label bg */
    color: white; /* Assuming secondary-color is dark enough for white text */
    border-radius: 15px; /* Pill shape, to match theme-toggle (30px height / 2) */
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s, transform 0.1s;
}

.share-button:hover {
    background-color: var(--primary-color); /* New hover color, distinct from new base */
}

.share-button:active {
    transform: scale(0.98);
}

.share-button i {
    font-size: 16px;
}

/* 主题切换开关 */
.theme-toggle {
    position: relative;
}

.theme-switch {
    opacity: 0;
    position: absolute;
}

.theme-switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    width: 50px;
    height: 26px;
    background-color: #83d8ff;
    border-radius: 100px;
    position: relative;
    transition: background-color 0.3s;
    padding: 0 5px;
}

.theme-switch:checked + .theme-switch-label {
    background-color: #4a4e69;
}

.theme-switch-label .fa-sun {
    color: #f39c12;
}

.theme-switch-label .fa-moon {
    color: #f1c40f;
}

/* 隐私提示框样式 */
.privacy-notice {
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease-in-out;
}

.privacy-notice-content {
    display: flex;
    align-items: center;
    background-color: var(--tip-background);
    border-left: 4px solid #2196f3;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.privacy-notice-content i.fa-shield-alt {
    font-size: 20px;
    color: #2196f3;
    margin-right: 15px;
}

.dark-theme .privacy-notice-content i.fa-shield-alt {
    color: #3498db;
}

.privacy-notice-content p {
    flex: 1;
    margin: 0;
    font-size: 14px;
    /* color: #37474f; */
    color: var(--text-color);
}

.dark-theme .privacy-notice-content p {
    color: #ecf0f1;
}

.close-notice {
    background: none;
    border: none;
    color: #90a4ae;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.close-notice:hover {
    color: #546e7a;
    background: none;
}

.dark-theme .close-notice {
    color: #b0bec5;
}

.dark-theme .close-notice:hover {
    color: #ecf0f1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .privacy-notice-content {
        flex-direction: column;
        text-align: center;
        padding: 15px 10px;
    }
    
    .privacy-notice-content i.fa-shield-alt {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .close-notice {
        position: absolute;
        top: 5px;
        right: 5px;
    }
}

.theme-switch-label .slider {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transition: 0.3s;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    left: 2px;
}

.theme-switch:checked + .theme-switch-label .slider {
    transform: translateX(24px);
}

/* 字段选择区域 */
.fields-checkboxes-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    overflow-y: auto; /*允许垂直滚动*/
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-background);
    height: 626px; /* 默认高度与json-input一致 */
}

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--primary-color);
}

.checkbox-item label {
    font-size: 0.9em;
    color: var(--text-color);
}

.export-buttons button:first-child {
    margin-left: 0;
}

.dark-theme .fields-checkboxes-container {
    border-color: var(--dark-border-color);
    background-color: var(--dark-input-bg-color);
}

.dark-theme .checkbox-item label {
    color: var(--dark-text-color);
}

.dark-theme .export-buttons button {
    background-color: var(--dark-primary-color);
}

.dark-theme .export-buttons button:hover {
    background-color: var(--dark-primary-hover-color);
}


/* 响应式设计 */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    
    .input-section, .output-section {
        min-height: 300px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}